package vip.xiaonuo.common.util;

import java.util.Map;

/**
 * @author 墨塵
 * @since 2023/3/2
 */
public class AliyunSmsUtil {

    /**
     * ${cab}断电后重新启动
     */
    public static final String POWER_OFF_RESTART = "SMS_270930171";

    /**
     * ${cabdoor}开门后,超过${outtime}分钟未关门
     */
    public static final String CLOSE_DOOR_TIMEOUT = "SMS_270955155";

    /**
     * ${goods}超期未归还,应${rettime}前归还,已超期${ovdhour}小时;检查时间:${time};检查动作:定期检查      SMS_270905147
     * ${goods}超期未归还,应${rettime}前归还,超期时间:${ovdhour};检查时间:${time};检查动作:定期检查      SMS_273700073
     */
    public static final String OVERDUE_NON_RETURN = "SMS_273700073";

    /**
     * ${item}应存入${errdoor},当前误存入${rightdoor},请及时调整;检查时间:${time};检查动作:${action};操作人:${user}
     */
    public static final String INCONSISTENT_WITHDRAWAL_RETURN = "SMS_271015093";

    /**
     * 柜子信息：${cabinetName}，异常内容：${msg}，当前值${value}，请确认现场环境。
     */
    public static final String ABNORMAL_ENVIRONMENT = "SMS_272591047";

    /**
     * 试剂“初始净量“异常 : 试剂：${reagentName}初始净量”为${reagentWeght}，大于首次称重${reagentInitWeght}，目前存放于试剂柜:${cabinetName}，请及时确认外理。检查时间: ${checkTime}
     */
    public static final String ABNORMAL_NETWEIGHT_REAGENT = "SMS_460770826";

    /**
     * 试剂存诸属性冲实:试剂：${reagentName}，与试剂柜：${cabinet}存在试剂类型冲突，请及时处理，检查时间: ${checkTIme}, 操作人: ${operator}.
     * SMS_460710129    替换  SMS_460791418
     * SMS_460791418    替换  SMS_460960198
     */
    public static final String REAGENT_STORAGE_CONFLICTS = "SMS_460960198";

    /**
     * 试剂柜超过最大承重:试剂${reagentName}存入后，试剂柜:${cabinet)超过最大承重，请及时处理。检查时间: ${checkTime}: 操作人，${operator}
     * SMS_460715149    替换  SMS_460895363
     * SMS_460895363    替换  SMS_461085175
     */
    public static final String REAGENT_CABINET_EMC = "SMS_461085175";


    private static String getTempCry(String smsId) {
        String result = "未知模板";

        if (smsId.equals("SMS_270930171")) {
            result = "${cab}断电后重新启动";
        }
        if (smsId.equals("SMS_270955155")) {
            result = "${cabdoor}开门后,超过${outtime}分钟未关门";
        }
        if (smsId.equals("SMS_273700073")) {
            result = "${goods}超期未归还,应${rettime}前归还,超期时间:${ovdhour};检查时间:${time};检查动作:定期检查";
        }
        if (smsId.equals("SMS_271015093")) {
            result = "${item}应存入${errdoor},当前误存入${rightdoor},请及时调整;检查时间:${time};检查动作:${action};操作人:${user}";
        }
        if (smsId.equals("SMS_272591047")) {
            result = "柜子信息：${cabinetName}，异常内容：${msg}，当前值${value}，请确认现场环境";
        }
        if (smsId.equals("SMS_460770826")) {
            result = "试剂“初始净量“异常 : 试剂：${reagentName}初始净量”为${reagentWeght}，大于首次称重${reagentInitWeght}，目前存放于试剂柜:${cabinetName}，请及时确认外理。检查时间: ${checkTime}";
        }
        if (smsId.equals("SMS_460960198")) {
            result = "试剂存诸属性冲实:试剂：${reagentName}，与试剂柜：${cabinet}存在试剂类型冲突，请及时处理，检查时间: ${checkTIme}, 操作人: ${operator}";
        }
        if (smsId.equals("SMS_461085175")) {
            result = "试剂柜超过最大承重:试剂${reagentName}存入后，试剂柜:${cabinet)超过最大承重，请及时处理。检查时间: ${checkTime}: 操作人，${operator}";
        }
        return result;
    }

    public static String getSmsCry(String smsId, Map<String, String> params) {
        String result = getTempCry(smsId);
        for (Map.Entry<String, String> entry : params.entrySet()) {
            result = result.replace("${" + entry.getKey() + "}", entry.getValue());
        }
        return result;
    }

}
